﻿using System;
using System.Collections.Generic;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PICCommands.Commands
{
    public class Rs232Command : IExecutable
    {
        public string Command { get; private set; }
        private readonly SerialPort _serialPort;

        public Rs232Command(SerialPort serialPort, string command)
        {
            Command = command;
            _serialPort = serialPort;
        }

        public void Execute()
        {
            if (!_serialPort.IsOpen) _serialPort.Open();
            _serialPort.WriteLine(Command);
        }


    }


}